package Tasks;

import Plants.PowerPlant;
import SmartGrid.ExecutionEngine;

/**
 * Steadily increases the electric output of a power plant until it reaches its cutoff point
 * @author jeffrey
 *
 */
public class IncrementElectricOutput extends MyRunnable{

	PowerPlant plant;
	int cutoff;
	
	public IncrementElectricOutput(PowerPlant plant, int cutoff)
	{
		this.plant = plant;
		this.cutoff = cutoff;
	}
	
	@Override
	public synchronized void run() {
		if(super.haltExecution()) return;
		if(plant.getElectricOutput() < cutoff)
		{
			if(!plant.isHighlighted())
				plant.setHighlighted(true);
			this.plant.incrementElectricOutput(Tools.Options.INCREMENT_ELECTRIC_OUTPUT_INCREMENT, true);
		}
		else
		{
			plant.setHighlighted(false);
			ExecutionEngine.cancelTask(this);
		}
	}

	
	
}
